package shuanfa.exercise;

import sun.reflect.generics.tree.Tree;

import java.util.TreeSet;

public class SymmetricBinaryTree {
    public static boolean compare(node node1,node node2){
        if (node1==null && node2 == null) return true;
        if (node1==null || node2==null) return false;
        return node1.value== node2.value && compare(node1.left,node2.right) && compare(node1.right,node2.left);
    }
    public static boolean isSymmetric(node root){
        if (root==null) return true;
        return compare(root.left,root.right);
    }


    public static void main(String[] args) {
        node zs = new node(1, "zs");
        node ls = new node(2, "ls");
        node ls1 = new node(3, "ls");
        zs.left=ls;
        zs.left.left=ls1;
        boolean symmetric = isSymmetric(zs);
        System.out.println(symmetric);
    }
}
class node{
    int index;
    String value;
    node left;
    node right;

    public node(int index, String value) {
        this.index = index;
        this.value = value;
    }
}
